package com.qiangqiang.repository;

import com.qiangqiang.entity.DorStu;
import com.qiangqiang.entity.Dormitory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.math.BigDecimal;

/**
 * Created by q on 2018/2/4.
 */
public interface DormitoryRepository extends JpaRepository<Dormitory,String> {
    //增加一个宿舍

    /**
     * 删除一个宿舍
     */

    @Modifying
    void deleteByDId(String dId);
    //根据宿舍号查询该宿舍所有的学生

    /**
     * 查询该宿舍总分
     */
    @Query(value = "select score from dormitory where d_id=:id",nativeQuery = true)
    BigDecimal queryScore(@Param("id") String dId);
}
